package com.ruoyi.whc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.whc.domain.Isolationpoint;
import com.ruoyi.whc.service.IIsolationpointService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隔离点管理Controller
 * 
 * @author whc
 * @date 2022-09-22
 */
@RestController
@RequestMapping("/whc/isolationpoint")
public class IsolationpointController extends BaseController
{
    @Autowired
    private IIsolationpointService isolationpointService;

    /**
     * 查询隔离点管理列表
     */
    @PreAuthorize("@ss.hasPermi('whc:isolationpoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(Isolationpoint isolationpoint)
    {
        startPage();
        List<Isolationpoint> list = isolationpointService.selectIsolationpointList(isolationpoint);
        return getDataTable(list);
    }

    /**
     * 导出隔离点管理列表
     */
    @PreAuthorize("@ss.hasPermi('whc:isolationpoint:export')")
    @Log(title = "隔离点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Isolationpoint isolationpoint)
    {
        List<Isolationpoint> list = isolationpointService.selectIsolationpointList(isolationpoint);
        ExcelUtil<Isolationpoint> util = new ExcelUtil<Isolationpoint>(Isolationpoint.class);
        util.exportExcel(response, list, "隔离点管理数据");
    }

    /**
     * 获取隔离点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('whc:isolationpoint:query')")
    @GetMapping(value = "/{isoid}")
    public AjaxResult getInfo(@PathVariable("isoid") Long isoid)
    {
        return AjaxResult.success(isolationpointService.selectIsolationpointByIsoid(isoid));
    }

    /**
     * 新增隔离点管理
     */
    @PreAuthorize("@ss.hasPermi('whc:isolationpoint:add')")
    @Log(title = "隔离点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Isolationpoint isolationpoint)
    {
        return toAjax(isolationpointService.insertIsolationpoint(isolationpoint));
    }

    /**
     * 修改隔离点管理
     */
    @PreAuthorize("@ss.hasPermi('whc:isolationpoint:edit')")
    @Log(title = "隔离点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Isolationpoint isolationpoint)
    {
        return toAjax(isolationpointService.updateIsolationpoint(isolationpoint));
    }

    /**
     * 删除隔离点管理
     */
    @PreAuthorize("@ss.hasPermi('whc:isolationpoint:remove')")
    @Log(title = "隔离点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{isoids}")
    public AjaxResult remove(@PathVariable Long[] isoids)
    {
        return toAjax(isolationpointService.deleteIsolationpointByIsoids(isoids));
    }
}
